# 作者: YYJ
# 2025年06月12日22时01分55秒
# 2486249622@qq.com


class CircleQueue:
    def __init__(self, max_size):
        self.max_size = max_size
        self.queue = [0] * max_size
        self.front = 0
        self.rear = 0

    def enqueue(self, value):
        if (self.rear + 1) % self.max_size == self.front:
            print("队列已满")
            return

        self.queue[self.rear] = value
        self.rear = (self.rear + 1) % self.max_size

    def dequeue(self):
        if self.front == self.rear:
            print("队列为空")
            return
        value = self.queue[self.front]
        self.front = (self.front + 1) % self.max_size
        return value


if __name__ == '__main__':
    q = CircleQueue(5)
    q.enqueue(1)
    q.enqueue(2)
    q.enqueue(3)
    q.enqueue(4)
    q.enqueue(5)
    print(q.queue)
    print(q.dequeue())
